/* --------------------------------------------------------------- */
/* class Application, the Application interface in GTK.            */
/* Authors:                                                        */
/* Emilio Blazquez Sierra                                          */
/* Francisco Fernandez Castaño                                     */
/* Maria Jesus Ciudad Trujillo                                     */
/* --------------------------------------------------------------- */


#include <gtkmm.h>
#include <gtkglmm.h>
#include <string>
#include <sstream>
#include <SDL/SDL.h>
#include <SDL/SDL_thread.h>


#include "GUI_Scene.h"


class Application : public Gtk::Window
{
 public:
  static const Glib::ustring APP_NAME;

 public:
  Application();
  virtual ~Application();


 protected:
  /* Signal handlers */

  /** \brief Handler of key events
   * \param event: event handled by Gtk
   */
  virtual bool on_key_press_event(GdkEventKey* event);
  /** \brief Show the scale window  */
  virtual void on_scale_button_press();
  /** \brief Show the rotate window */
  virtual void on_button_rotate_clicked();
  /** \brief Show the translate window */
  virtual void on_translate_button_press();
  /* * \brief Show the import window */
  // virtual void on_import_button_press();
  /** \brief Show the extrude window */
  virtual void on_extrude();
  /** \brief Manage the window of scale
   *     Taking data from the textbox and check box and sending it
   *      to corresponding function */
  virtual void on_scale_button();
  /** \brief Manage the window of rotation
   *     Taking data from the textbox and check box and sending it
   *      to corresponding function */
  virtual void on_rotate_button();
  /** \brief Manage the window of translation
   *     Taking data from the textbox and sending it
   *      to corresponding function */
  virtual void on_translate_button();
  /** \brief Manage the edit/object mode calling to corresponding function*/
  virtual void on_edit_button_click();
  /** \brief Manage the window of scale
   *     Taking data from the textbox and sending it
   *      to corresponding function */
  virtual void on_extrude_action();
  /** \brief Manage delete button calling m_Scene.delete_objects() */
  virtual void on_delete();
  /** \brief Manage select all button calling m_Scene.selectall() */
  virtual void selectall();
  /** \brief Manage  Select Inverse button calling m_Scene.selectinverse() */
  virtual void selectinverse();
  /** \brief Manage Deselect all button calling m_Scene.deselectall() */
  virtual void deselectall();
  /** \brief Connect signals of buttons with corresponding methods */
  void connects();
  /** \brief Manage the main menu */
  virtual Gtk::Menu* create_file_menu();
  /** \brief Create a new scene */
  virtual void New(int x);
  /** \brief Manage import window */
  virtual void Import(int x);
  /** \brief Manage import window */
  virtual void Export(int x);
  /** \brief Manage the window of import
   *     Taking data from the textbox and sending it
   *      to corresponding function */
  virtual void import_action();
  /** \brief Manage the window of export
   *     Taking data from the textbox and sending it
   *      to corresponding function */
  virtual void export_action();

 protected:
  bool editmode;
  // member widgets:
  Gtk::VBox m_VBox;
  Gtk::HBox m_HPaned;
  Gtk::MenuBar m_MBar;
  Gtk::MenuItem m_MItem;
  Gtk::Menu m_Submenu;
  Gtk::MenuItem m_MItemShapes;
  Gtk::Menu* m_Shapes_menu;
  Gtk::Menu* m_FileMenu;
  Gtk::VButtonBox m_VBBox;
  Gtk::VButtonBox m_VBBox2;
  Gtk::Label edobmod;

  /** \brief Rotate Window widget for glade file import */
  Gtk::Window *rotateWindow;
  /** \brief Scale Window widget for glade file import */
  Gtk::Window *scaleWindow;
  /** \brief Translate Window widget for glade file import */
  Gtk::Window *translateWindow;
  /** \brief Error Window widget for glade file import */
  Gtk::Window *error;
  /** \brief Extrude Window widget for glade file import */
  Gtk::Window *extrudeWin;

  /** \brief Import Window widget for glade file import */
  Gtk::Window *impwin;
  /** \brief Export Window widget for glade file import */
  Gtk::Window *expwin;



  Gtk::Button select_all;
  Gtk::Button select_inverse;
  Gtk::Button deselect_all;

  Gtk::Button m_ButtonEdit;
  Gtk::Button m_ButtonRotate;
  Gtk::Button r_scale;
  Gtk::Button r_translate;
  Gtk::Button* button3;

  //Widgets of rotate window
  Gtk::Entry* rotx;
  Gtk::CheckButton* rx;
  Gtk::CheckButton* ry;
  Gtk::CheckButton* rz;

  //Widgets of Translate window
  Gtk::Button* buttont;
  Gtk::Entry* tx;
  Gtk::Entry* ty;
  Gtk::Entry* tz;

  //Widgets of scale window
  Gtk::Button* buttons;
  Gtk::Entry* scax;
  Gtk::CheckButton* sx;
  Gtk::CheckButton* sy;
  Gtk::CheckButton* sz;

  Gtk::Button del;
  Gtk::Button Extr;

  //Widgets of extrude window
  Gtk::Button* buttonex;
  Gtk::Entry* distext;

  //Widgets of extrude window
  Gtk::Button* buttonim;
  Gtk::Entry* pathimp;

  //Widgets of export window
  Gtk::Button* buttonexport;
  Gtk::Entry* pathexp;


  // Scene
  GUIScene m_Scene;
};


